﻿using System;
/* 
 *  <copyright file="PlatformerScreen.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using Microsoft.Xna.Framework;
using SEGameExample.Kludge;
using SEGameExample.InputMappers;
using SobrietyEngine.Actor;
using SobrietyEngine.Logging;
using SobrietyEngine.Scene;
using SobrietyEngine.Screens;

namespace SEGameExample.Screens
{
    class HugeMeshLevel: BaseLevel
    {
        public HugeMeshLevel()
            : base("HugeMeshScreen")
        {
        }

        public override void Initialize()
        {
            base.Initialize();
            
            //set up our PlayerOne (first found user with an Xbox 360 controller)
            //turn off any controllers that may be active (shoudl always disable controllers when you are finished!)
            PlayerOne.DisableAllInputMappers();
            if (!PlayerOne.HasInputMapper(typeof(PlatformerEventMapper)))
                PlayerOne.AddInputMapper(new PlatformerEventMapper(EventRouter, PlayerOne.Guid));
            PlayerOne.EnableInputMapper(typeof(PlatformerEventMapper));

            //forward declaration of some variables used in here
            IActor actor = null;
            IScene scene = SceneGameService.Scenes[SceneName];


            //Test some gui and hud stuff
            //create a 2D gui camera     
            //IActor cam2D = GUISpawner.Camera2D(Scene, ScreenManager.FullScreenViewport);
            IActor cam2d = SobrietyEngine.Actor.Builders.Cameras.GuiCameraBldr.Build(Scene, ScreenManager.FullScreenViewport);

            //some help text about controls
            String help = "Generated static geom from an 8K face mesh.\n";
            help += "Mesh was found in Googlesketchup warehouse\n";
            help += "Left thumbstick moves\n";
            help += "(A) jumps, (RB) super jumps, \n";
            help += "(B) exits, (Y) toggles physics debug \n";
            help += "(LB) toggle debug console\n";

            SobrietyEngine.Actor.Builders.GUI.Text2D.Build(Scene, new Vector2(0, ScreenManager.FullScreenViewport.Height / 2), help);

            GameplaySpawner.Level(Scene, "Meshes/Mario/Untitled", ScreenManager.Game);

            //create out platform player 
            IActor playerActor = GameplaySpawner.PlatformerPlayer2D(scene, new Vector2(-3, 2), PlayerOne.Guid, ScreenManager.GraphicsDevice, FarseerPhysics.Dynamics.Category.Cat1, textureManager);
            // playerActor.Get<IFarseerPhysicsBody>().Body.IgnoreGravity = true;

            //create 3D Scene camera that trys to follow the player
            actor = GameplaySpawner.OrthoFollowActorCam3D(scene, ScreenManager.FullScreenViewport, ScreenManager.GraphicsDevice, playerActor.Guid);

            //turn on our controllers
            SceneGameService.Scenes[SceneName].EnableControllers();
        }

    }
}